package com.qst.mapreduce.wordcount.mahongsen;

import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class App implements WritableComparable<App>{
    private double price;
    private String time;

    //重写序列化write方法和重写反序列化readFields方法
    public void write(DataOutput dataOutput) throws IOException
    {
        dataOutput.writeDouble(price);
        dataOutput.writeUTF(time);
    }
    public void readFields(DataInput dataInput) throws IOException
    {
        price = dataInput.readDouble();
        time = dataInput.readUTF();
    }
    public String toString() {
        return price+"\t"+time;
    }
    //重写比较方法
    public int compareTo(App app) {
        if(this.price>app.price)
        {
            return -1;
        }
        else if(this.price<app.price)
        {
            return 1;
        }
        else
        {
            return 0;
        }
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }
}
